|
|
|
|
|
|
|
Figure 28.1
The API Text Viewer. |
|
|
|
|
|
|
|
|
After you have a declaration in your program, you can now execute that function just like any other function in Visual Basic. Visual Basic takes care of loading the DLL, passing your parameters to the routine, and returning any values back. When calling API functions, you can pass parameters by value or by reference, just like in Visual Basic. However, note that when youre using string parameters, the ByVal keyword has a different meaning. |
|
|
|
|
|
|
|
|
Call by Reference Versus Call by Value |
|
|
|
|
|
|
|
|
When passing parameters to an API function, you must take care to ensure that you pass the correct data type and value. Some API functions want just a copy of the data (a call by value), whereas others actually want the pointer to the variable in memory (a call by reference). You can look at the declarations to determine whether the function wants a copy of the data or a pointer. If you see the ByVal keyword in front of a numeric parameter, it means the function is expecting a copy of the data. For string parameters, however, its completely different. A Visual Basic string is really a pointer to another area of memory where the string is actually located. Because this is different than a C language string, the ByVal keyword must do some translation. |
|
|
|
|
|